# Points to the root of Google Test, relative to where this file is.
# Remember to tweak this if you move this file.
GTEST_DIR = gtest-1.6.0/

# All Google Test headers.  Usually you shouldn't change this
# definition.
GTEST_HEADERS = $(GTEST_DIR)/include/gtest/*.h \
                $(GTEST_DIR)/include/gtest/internal/*.h

# Where to find user code.
USER_DIR = ./

# Flags passed to the preprocessor.
CPPFLAGS += -I$(GTEST_DIR)/include

# Flags passed to the C++ compiler.
CXXFLAGS += -g -Wall -Wextra

PROG=ReportSystem
OBJS=main.o LoginSystem.o CommandHelper.o TranscriptFactory.o Transcript_JohnDoe.o Transcript_AbeLincoln.o CheckCourse.o ShowProgress.o Student.o User.o Command.o DGS.o ShowStudentList.o ShowGpa.o ShowTranscript.o 

TESTS=TestGetStudent TestGetType
TESTS_OBJS=CommandHelper.o TranscriptFactory.o Transcript_JohnDoe.o Transcript_AbeLincoln.o

#Compile everything using default rules.
all: ${PROG}

${PROG}: ${OBJS}
	${CXX} ${CPPFLAGS} ${CXXFLAGS} -o $@ ${OBJS} ${LDFLAGS}

tests: ${TESTS}
 
TestGetStudent : $(TESTS_OBJS) TestGetStudent.o gtest_main.a
	$(CXX) $(CPPFLAGS) $(CXXFLAGS) -lpthread $^ -o $@ 
	
TestGetType : $(TESTS_OBJS) TestGetType.o gtest_main.a
	$(CXX) $(CPPFLAGS) $(CXXFLAGS) -lpthread $^ -o $@ 
	
#Removes the object files only.
clean: 
	rm -f *.o gtest.a gtest_main.a ${PROG} ${TESTS} 

#Cleans the object files and program
cleanall: clean
	rm -f ${PROG}
	            
# Usually you shouldn't tweak such internal variables, indicated by a
# trailing _.
GTEST_SRCS_ = $(GTEST_DIR)/src/*.cc $(GTEST_DIR)/src/*.h $(GTEST_HEADERS)

# For simplicity and to avoid depending on Google Test's
# implementation details, the dependencies specified below are
# conservative and not optimized.  This is fine as Google Test
# compiles fast and for ordinary users its source rarely changes.
gtest-all.o : $(GTEST_SRCS_)
	$(CXX) $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -c \
            $(GTEST_DIR)/src/gtest-all.cc

gtest_main.o : $(GTEST_SRCS_)
	$(CXX) $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -c \
            $(GTEST_DIR)/src/gtest_main.cc

gtest.a : gtest-all.o
	$(AR) $(ARFLAGS) $@ $^

gtest_main.a : gtest-all.o gtest_main.o
	$(AR) $(ARFLAGS) $@ $^

# Builds a sample test.  A test should link with either gtest.a or
# gtest_main.a, depending on whether it defines its own main()
# function.

#CommandHelper.o : $(USER_DIR)/CommandHelper.cpp $(USER_DIR)/CommandHelper.h $(GTEST_HEADERS)
#	$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(USER_DIR)/CommandHelper.cpp
#	
#TranscriptFactory.o : $(USER_DIR)/TranscriptFactory.cpp $(USER_DIR)/TranscriptFactory.h $(GTEST_HEADERS)
#	$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(USER_DIR)/TranscriptFactory.cpp
#
#Transcript_AbeLincoln.o : $(USER_DIR)/Transcript_AbeLincoln.cpp $(USER_DIR)/Transcript_AbeLincoln.h $(GTEST_HEADERS)
#	$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(USER_DIR)/Transcript_AbeLincoln.cpp
#
#Transcript_JohnDoe.o : $(USER_DIR)/Transcript_JohnDoe.cpp $(USER_DIR)/Transcript_JohnDoe.h $(GTEST_HEADERS)
#	$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(USER_DIR)/Transcript_JohnDoe.cpp

TestGetStudent.o : $(USER_DIR)/TestGetStudent.cpp \
                     $(USER_DIR)/CommandHelper.h $(GTEST_HEADERS)
	$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(USER_DIR)/TestGetStudent.cpp
	
TestGetType.o : $(USER_DIR)/TestGetType.cpp \
                     $(USER_DIR)/CommandHelper.h $(GTEST_HEADERS)
	$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(USER_DIR)/TestGetType.cpp

	